package com.grupoconstruobras.sigo.exhumaciones.ui.mapper;

import com.grupoconstruobras.sigo.mapper.IMapper;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

public class ObjectMapper implements IMapper<List<SelectItem>, Object []> {

	@Override
	public List<SelectItem> mapper(List<Object []> beans) {
		List<SelectItem> items = new ArrayList<SelectItem>();
		for(Object [] row : beans) {
			int columns = row.length;
			if(columns == 1)
				items.add(new SelectItem(row[0]));
			if(columns == 2)
				items.add(new SelectItem(row[0], (String) row[1]));
			if(columns == 3)
				items.add(new SelectItem(row[0], (String) row[1], (String) row[2]));
			if(columns == 4)
				items.add(new SelectItem(row[0], (String) row[1], (String) row[2], (Boolean) row[3]));
			if(columns == 5)
				items.add(new SelectItem(row[0], (String) row[1], (String) row[2], (Boolean) row[3], (Boolean) row[4]));
			if(columns == 6)
				items.add(new SelectItem(row[0], (String) row[1], (String) row[2], (Boolean) row[3], (Boolean) row[4], (Boolean) row[4]));
		}
		return items;
	}

}
